#include<iostream>
#include<string>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10;
int n, m;
int arr[N], s[11][N];
int main()
{
	cin >> n >> m;
	LL ans1 = 0;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		/*LL sum = arr[i] * arr[i];
		if (sum % m == 0) {
			ans1++;
		}*/
	}
	for (int i = 0; i < n; i++) {
		LL t = arr[i] % m;
		for (int j = 0; j < 11; j++) {
			s[j][t]++;
			t = t * 10 % m;
		}
	}
	LL ans = 0;
	for (int i = 0; i < n; i++) {
		LL t = arr[i] % m;
		int len = to_string(arr[i]).size();
		ans += s[len][(m - t) % m];
		LL r = t;
		while (len--) {
			r = r * 10 % m;
		}
		if (r == (m - t) % m) {
			ans--;
		}
	}
	cout << ans  << endl;
	return 0;
}